﻿using System.Collections.Generic;

namespace Chimp.Core
{
    public class xOperatorMultiply : ChimpFXNode
    {
        public xOperatorMultiply() : base("Multiply", EffectNodeType.Operation)
        {
            AddIn(EffectParameterType.Anything, "Value1", "First Value");
            AddIn(EffectParameterType.Anything, "Value2", "Second Value");
            AddOut(EffectParameterType.Anything, "OutputValue", "Result Value");
        }

        public override ChimpFXNode CreateNew()
        {
            return new xOperatorMultiply();
        }

        public override void ProduceSegment(List<ChimpEffectPar> pars)
        {
            ChimpEffectPar p1 = pars[0];
            ChimpEffectPar p2 = pars[1];
            //        switch (p1.To.Type)
            //          {

//                case EffectParameterType.Float:
            PropNodeName = "floatResult";
            if (ChimpFX.MainCode.Contains("float floatResult_" + Out[0].ID + ";"))
            {
            }
            else
            {
                ChimpFX.Code("float floatResult_" + Out[0].ID + ";");
            }
            ChimpFX.Code("floatResult_" + Out[0].ID + " = " + InTo(0) + " * " + InTo(1) + ";");
            //X.Code("floatResult_"+Out[0].ID+" = " + InTo(0) + " * " + InTo(1) + ";");

            Out[0].Type = EffectParameterType.Float;

            return;
            //default:


            ChimpFX.Code("//code-generation faliure here.Node:" + ID + " Type:" + NodeType);
        }
    }
}